package com.nxuer.controllers.pkg01;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.InputStream;
import java.util.ArrayList;

@Service
public class Dao {
    InputStream in;
    SqlSessionFactory sqlSessionFactory;
    SqlSession sqlSession;
    DataMapper d;
    Dao() {
        in = Resource.class.getResourceAsStream("/mybatis-config.xml");
        sqlSessionFactory = new SqlSessionFactoryBuilder().build(in);
        sqlSession = sqlSessionFactory.openSession();
        d = sqlSession.getMapper(DataMapper.class);
    }
    ArrayList<MeteData> QueryMeteData(int date) {
        return d.query("a" + date);
    }
}
